package lab02.test29;

import java.util.Scanner;

public class Test29 {
    public static void main(String[] args) {
        int[] array = {1,2,3,4,5};
        System.out.println("请输入你要访问数组的第几个元素.");
        Scanner sc = new Scanner(System.in);
        int i = sc.nextInt();

        try {
            int a = array[i];
            System.out.println("访问成功.");
        }catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("数组元素越界.");
        } finally {
            System.out.println("程序结束.");
        }
    }
}
